/**
 * Created by Guoliang on 2017/11/5.
 */
$(function(){
    $('.rule').click(function(){
        var status = $(this).attr('status');
        if(status){
            $('.rule').attr('status',1);
            $('.rule').attr('checked',true);
            $('button').attr('disabled',false);
        }
        if(status == 1){
            $('.rule').attr('status',0);
            $('.rule').attr('checked',false);
            $('button').attr('disabled',true);
        }
    });
    $('.b1').click(function(){
        var status = $('#reader-me').attr('status');
        if(status == 0){
            return layer.msg('请阅读协议');
        }
        var uri =$('#mail').attr('action');
        var data = $("form[id=mail]").serialize();
        ajaxPost(uri, $(".b1"), data, function(r){
            $(".b1").removeAttr("disabled");
            location.href = r.url;
        });
    });
    /*
    * 获取手机验证码
    * */
    $('#sendMobileCode').click(function(){
        var phone = $('#phone').val();
        if(!(/^1[34578]\d{9}$/.test(phone))){
            return layer.msg("手机号码有误，请重填");
        }
        var data = {phone:phone};
        ajaxPost(sms, $("#sendMobileCode"), data, function(r){
            $("#sendMobileCode").removeAttr("disabled");
           /* location.href = r.url;*/
        });
    });
    $('.b2').click(function(){
        var status = $('#readerme').attr('status');
        if(status == 0){
            return layer.msg('请阅读协议');
        }
        var uri =$('#mobile').attr('action');
        var data = $("form[id=mobile]").serialize();
        ajaxPost(uri, $(".b2"), data, function(r){
            $(".b2").removeAttr("disabled");
            location.href = r.url;
        });
    });
    /*
    * 登陆
    * */
    $('.login').click(function(){
        var uri =$('#login').attr('action');
        var data = $("form[id=login]").serialize();
        ajaxPost(uri, $(".login"), data, function(r){
            $(".login").removeAttr("disabled");
            location.href = r.url;
        });
    });

})